package com.czk.scala.chapter05

/**
 * 函数的定义
 *
 * @Author:ChenZhangKun
 * @Date: 2021/12/8 17:02
 */
object Test01_FunctionAndMethod {
  def main(args: Array[String]): Unit = {
    // 直接定义函数
    def sayHi(name: String): Unit = {
      println("hello" + name)
    }

    def sayHi2(name: String): String = {
      println("hello" + name)
      "czk"
    }
    // 默认调用内部的函数
    sayHi("czk")
    val kd: String = sayHi2("kd")
    println(kd)
    // 调用对象的方法
    Test01_FunctionAndMethod.sayHi("nzq")
  }

  // 定义对象的方法
  def sayHi(name: String): Unit = {
    println("Hi" + name)
  }
}
